package com.xianbeiying.app.ckgl.activity;

import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.xianbeiying.app.ckgl.R;
import com.xianbeiying.app.ckgl.fragment.EsDiagnoseFragment;
import com.xianbeiying.app.ckgl.fragment.EsSubscribeFragment;

/**
 * 专家系统
 * */
public class ExpertSystemActivity extends BaseActivity  implements View.OnClickListener{
    private TextView tv_title;
    private ImageView iv_title_left;
    //专家预约
    private LinearLayout ly_zjyl;
    private TextView tv_zjyl,tv_yl_line;
    //远程诊断
    private LinearLayout ly_yczd;
    private TextView tv_yczd,tv_yczd_line;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        isPermisson=true;
        setContentView(R.layout.activity_expert_system);
        initView();
    }

    private void initView() {
        iv_title_left=(ImageView) findViewById(R.id.iv_title_left);
        tv_title=(TextView) findViewById(R.id.tv_title);
        ly_zjyl=(LinearLayout) findViewById(R.id.ly_zjyl);
        tv_zjyl=(TextView) findViewById(R.id.tv_zjyl);
        tv_yl_line=(TextView) findViewById(R.id.tv_yl_line);
        ly_yczd=(LinearLayout) findViewById(R.id.ly_yczd);
        tv_yczd=(TextView) findViewById(R.id.tv_yczd);
        tv_yczd_line=(TextView) findViewById(R.id.tv_yczd_line);
        tv_title.setText("专家系统");
        initEvent();
    }

    private void initEvent() {
        iv_title_left.setOnClickListener(this);
        ly_zjyl.setOnClickListener(this);
        ly_yczd.setOnClickListener(this);
        tv_zjyl.setSelected(true);
        tv_yl_line.setVisibility(View.VISIBLE);
        getSupportFragmentManager().beginTransaction().
                replace(R.id.ly_es, EsSubscribeFragment.getInstance()).commit();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            //返回
            case R.id.iv_title_left:
                 finish();
                break;
            //专家预约
            case R.id.ly_zjyl:
                showDefault();
                tv_zjyl.setSelected(true);
                tv_yl_line.setVisibility(View.VISIBLE);
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.replace(R.id.ly_es, EsSubscribeFragment.getInstance());
                transaction.commit();
                break;
            //远程诊断
            case R.id.ly_yczd:
                showDefault();
                tv_yczd.setSelected(true);
                tv_yczd_line.setVisibility(View.VISIBLE);
                FragmentTransaction transactions= getSupportFragmentManager().beginTransaction();
                transactions.replace(R.id.ly_es, EsDiagnoseFragment.getInstance());
                transactions.commit();
                break;

        }
    }
    private void showDefault(){
        tv_zjyl.setSelected(false);
        tv_yl_line.setVisibility(View.GONE);
        tv_yczd.setSelected(false);
        tv_yczd_line.setVisibility(View.GONE);
    }
}
